//'Python.h' is always needed
#include <Python.h>

//wrapper is needed for every method you want to use in python
//wrapper for linux shell system call
PyObject * wrap_sysCall (PyObject * self, PyObject * args )
{
	const char * command ;
	int result ;

	//Change python parameters into c/c++ format.
	if ( ! PyArg_ParseTuple(args, "s", &command) )
		return NULL ;
	
	//Call the c/c++ functions
	result =  sysCall ( command ) ;

	//Change c/c++ result into python format.
	return Py_BuildValue ( "i", result ) ;
}

//wrapper for fact of n (n!).
PyObject * wrap_fact (PyObject * self, PyObject * args )
{
	int n ;
	int result ;

	if ( ! PyArg_ParseTuple(args, "i", &n) )
		return NULL ;
	
	result =  fact ( n ) ;
	return Py_BuildValue ( "i", result ) ;
}

//module name is 'whqUtility'
static PyMethodDef whqUtilityMethods[] = 
{
	{ "sysCall", wrap_sysCall, METH_VARARGS, "System Call" },
	{ "fact", wrap_fact, METH_VARARGS, "Calculate the fact of natural number - n!" },
	{ NULL, NULL }
} ;

void initwhqUtility()
{
	PyObject * m ;

	m = Py_InitModule ( "whqUtility", whqUtilityMethods ) ;
}

